package blue.mqtt4j.core.util;

import java.util.Collection;
import java.util.Map;

/**
 * @author Jin Zheng
 * @since 1.0 2020-10-16
 */
public class AssertUtil
{
	private AssertUtil()
	{
	}

	public static void isEmpty(String text, String name)
	{
		if (text == null || text.isEmpty())
		{
			throw new IllegalArgumentException(name + " is empty");
		}
	}

	public static void isEmpty(Collection<?> collection, String name)
	{
		if (collection == null || collection.isEmpty())
		{
			throw new IllegalArgumentException(name + " is empty");
		}
	}

	public static void isEmpty(Map<?, ?> map, String name)
	{
		if (map == null || map.isEmpty())
		{
			throw new IllegalArgumentException(name + " is empty");
		}
	}

	public static void isNull(Object object, String name)
	{
		if (object == null)
		{
			throw new IllegalArgumentException(name + " is null");
		}
	}

}
